home *** CD-ROM | disk | FTP | other *** search
Java Source | 2001-06-13 | 1.1 KB | 60 lines |
- import java.awt.*;
-
- public class copytext extends java.applet.Applet
- {
- TextField tf1, tf2;
- public void init()
- {
- setLayout(new BorderLayout());
-
- Panel p;
-
- p = new Panel();
-
- p.setLayout(new GridLayout(0, 2));
-
- p.add(new Label("Type Text Here:"));
- tf1 = new TextField("");
- p.add(tf1);
-
- p.add(new Label("Click Button to Copy:"));
- tf2 = new TextField("");
- p.add(tf2);
-
- add("North", p);
-
- p = new Panel();
-
- p.setLayout(new GridLayout(1, 3));
- p.add(new Label(""));
- p.add(new Button("Copy"));
- p.add(new Label(""));
- add("South", p);
-
- }
-
- public boolean action(Event evt, Object arg) {
- if (evt.target instanceof Button) {
- String s1 = tf1.getText();
- tf2.setText(s1);
- return true;
- } // end action()
- return false;
- }
-
- public static void main(String [] args)
- {
- Frame f = new Frame("copytext");
-
- copytext ex = new copytext();
-
- ex.init();
-
- f.add("Center", ex);
-
- f.pack();
- f.show();
- }
-
- }
-